<script setup>
import {onMounted, reactive} from "vue";
import {getBanner} from "@/api/home.js";

let homeData = reactive({
  banner:[]
});

async function getHomeBanner() {
  const {data: res} = await getBanner();

  if (res && res.code === 200) {
    homeData.banner = res.data
  }
}

onMounted(() => {
  getHomeBanner();
});
</script>

<template>
  <el-carousel autoplay :interval="1500" type="card" height="400px" >
    <el-carousel-item v-for="item in homeData.banner" :key="item">
      <img :src="item.url" style="width: 100%;height: 100%">
    </el-carousel-item>
  </el-carousel>
</template>

<style scoped>
.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
